<template>
	<view>
		<scroll-view class="wrap-tab flex" scroll-x>
			<block v-for="(item, index) in list" :key="index">
				<view class="item" @click.stop="onTab(item, index)">
					<view
						class="title f-30"
						:class="{ choose: currentIndex == index }"
					>
						啊啊啊
					</view>
				</view>
			</block>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		props: {
			/**
			 * 列表
			 */
			list: {
				type: Array,
				default: [],
			},
		},
		data() {
			return {
				currentIndex: -1,
			};
		},
		methods: {
			/**
			 * 选择
			 */
			onTab(item, index) {
				this.currentIndex = index;
			},
		},
	};
</script>

<style lang="scss" scoped>
	.wrap-tab {
		width: 100%;
		overflow: hidden;
		white-space: nowrap;
		background-color: white;

		.item {
			display: inline-block;
			padding: 0 20rpx;
			overflow: hidden;

			.title {
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				overflow: hidden;
				box-sizing: border-box;
				color: #333;
				border-bottom: 6rpx solid white;
			}

			.choose {
				color: $theme-color;
				border-bottom-color: $theme-color;
			}
		}
	}
</style>
